package com.ankang.art.service.impl;

import com.ankang.art.dto.ExamineeDto;
import com.ankang.art.dto.QueryStudentDto;
import com.ankang.art.mapper.ExamineeMapper;
import com.ankang.art.pto.ExamineePto;
import com.ankang.art.service.ExamineeService;
import com.ankang.art.vo.Examinee;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ExamineeServiceImpl implements ExamineeService {

    @Autowired
    private ExamineeMapper examineeMapper;


    //删除考生信息
    @Override
    public boolean deleteExaminees(String idCard) {
        examineeMapper.deleteExaminees(idCard);
        return true;
    }


    //添加考生信息
    @Override
    public boolean saveExaminees(ExamineeDto examineeDto) {
        if(examineeDto!=null){
            examineeMapper.saveExaminees(examineeDto);
            return true;
        }else {
            return false;
        }

    }

    //修改考生信息
    @Override
    public boolean updateExaminees(ExamineeDto examineeDto) {
        if(examineeDto!=null){
            examineeMapper.updateExaminees(examineeDto);
            return true;
        }else {
            return false;
        }

    }

    @Override
    public List<Examinee> getExaminees(Integer pageNo, Integer pageSize, String name, Integer gender, String idCard, String schoolName, String status) {


        PageHelper.startPage(pageNo,pageSize);

        List<Examinee> allExaminees = examineeMapper.getExaminees(name,gender,idCard,schoolName,status);

        //List<Examinee> allExaminees = examineeMapper.getAllExaminees();
//
//        List<ExamineePto> examineePtoArrayList = new ArrayList<>();
//        if(!allExaminees.isEmpty()){
//            for (Examinee examinee : allExaminees) {
//                ExamineePto examineePto = new ExamineePto();
////                System.out.println(examinee);
//                BeanUtils.copyProperties(examinee,examineePto);
////                System.out.println(examineePto);
//                examineePtoArrayList.add(examineePto);
//            }
//        }
        return allExaminees;
    }

    @Override
    public List<Examinee> getExamTest() {
        List<Examinee> examineeList = examineeMapper.getExamTest();
        return examineeList;
    }

    @Override
    public List<Examinee> addExamTest() {
        List<Examinee> examineeList = examineeMapper.addExamTest();
        return examineeList;
    }

}
